package com.example.demo.excelUtils;

import com.example.demo.mode.User;
import org.junit.Before;
import org.junit.Test;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author pengyifeng
 * @version 2.0
 * @ClassName TestExcel.java
 * @Description TODO
 * @createTime 2021年11月03日 16:31:00
 */
public class TestExcel {
    List<User> userList;
    @Before
    public void testData(){
        userList=new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setName("小明"+i);
            user.setAge(16+i);
            userList.add(user);
        }


    }
    @Test
    public void testEx() throws FileNotFoundException {
        List<SheetDTO> sheetList = new ArrayList<SheetDTO>();




        SheetDTO sheet1 = new SheetDTO();
        sheet1.setTitles(new String[]{"标题1","标题2"});
        sheet1.setProperties(new String[]{"name","age"});
        sheet1.setSheetName("sheet1");
        sheet1.setCollection(userList);
        sheetList.add(sheet1);


        SheetDTO sheet2 = new SheetDTO();
        sheet2.setTitles(new String[]{"标题1","标题2"});
        sheet2.setProperties(new String[]{"name","age"});
        sheet2.setSheetName("sheet2");
        sheet2.setCollection(userList);
        sheetList.add(sheet2);


        SheetDTO sheet3 = new SheetDTO();
        sheet3.setTitles(new String[]{"标题1","标题2"});
        sheet3.setProperties(new String[]{"name","age"});
        sheet3.setSheetName("sheet3");
        sheet3.setCollection(userList);
        sheetList.add(sheet3);

        HuExcelUtils.exportExcel(null, sheetList, "政策上账导出");
    }

}
